--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit 6038bc541cd82ffce36176e9f8668efb863b7e7c
Parents : 3a95233
Author : Mark Qvist <mark@unsigned.io>
Date : 2024-09-14T19:55:25+02:00
Get link establishment rates via service on Android
Changes
2 files changed, 45 insertions(+), 9 deletions(-)
Diff
diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py
index 97b23336..aa40c045 100644
--- a/sbapp/sideband/core.py
+++ b/sbapp/sideband/core.py
@@ -1578,7 +1578,45 @@ class SidebandCore():
RNS.log(ed, RNS.LOG_DEBUG)
return ed
-
+ def _get_destination_establishment_rate(self, destination_hash):
+ try:
+ mr = self.message_router
+ oh = destination_hash
+ ol = None
+ if oh in mr.direct_links:
+ ol = mr.direct_links[oh]
+ elif oh in mr.backchannel_links:
+ ol = mr.backchannel_links[oh]
+
+ if ol != None:
+ ler = ol.get_establishment_rate()
+ if ler:
+ return ler
+
+ return None
+
+ except Exception as e:
+ RNS.trace_exception(e)
+ return None
+
+ def get_destination_establishment_rate(self, destination_hash):
+ if not RNS.vendor.platformutils.is_android():
+ return self._get_destination_establishment_rate(destination_hash)
+ else:
+ if self.is_service:
+ return self._get_destination_establishment_rate(destination_hash)
+ else:
+ try:
+ if self.rpc_connection == None:
+ self.rpc_connection = multiprocessing.connection.Client(self.rpc_addr, authkey=self.rpc_key)
+ self.rpc_connection.send({"get_destination_establishment_rate": destination_hash})
+ response = self.rpc_connection.recv()
+ return response
+ except Exception as e:
+ ed = "Error while getting destination link etablishment rate over RPC: "+str(e)
+ RNS.log(ed, RNS.LOG_DEBUG)
+ return None
+
def __start_rpc_listener(self):
try:
RNS.log("Starting RPC listener", RNS.LOG_DEBUG)
@@ -1621,6 +1659,8 @@ class SidebandCore():
connection.send(True)
elif "get_plugins_info" in call:
connection.send(self._get_plugins_info())
+ elif "get_destination_establishment_rate" in call:
+ connection.send(self._get_destination_establishment_rate(call["get_destination_establishment_rate"]))
elif "send_message" in call:
args = call["send_message"]
send_result = self.send_message(
diff --git a/sbapp/ui/objectdetails.py b/sbapp/ui/objectdetails.py
index 6acb51f0..38d00745 100644
--- a/sbapp/ui/objectdetails.py
+++ b/sbapp/ui/objectdetails.py
@@ -796,14 +796,10 @@ class RVDetails(MDRecycleView):
self.entries.append({"icon": "routes", "text": f"Current path on [b]{nhi}[/b]", "on_release": pass_job})
try:
- mr = self.delegate.app.sideband.message_router
- oh = self.delegate.object_hash
- if oh in mr.direct_links:
- ol = mr.direct_links[oh]
- ler = ol.get_establishment_rate()
- if ler:
- lers = RNS.prettyspeed(ler, "b")
- self.entries.append({"icon": "lock-check-outline", "text": f"Direct link established, LER is [b]{lers}[/b]", "on_release": pass_job})
+ ler = self.delegate.app.sideband.get_destination_establishment_rate(self.delegate.object_hash)
+ if ler:
+ lers = RNS.prettyspeed(ler, "b")
+ self.entries.append({"icon": "lock-check-outline", "text": f"Direct link established, LER is [b]{lers}[/b]", "on_release": pass_job})
except Exception as e:
RNS.trace_exception(e)
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────